package com.gioneco.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.gioneco.enumerate.OperateTypeEnum;
import com.gioneco.util.FieldTag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * 系统操作日志  DTO
 * @author dongjialin
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Document(indexName = "iot-log*")
public class SystemLogDO {

    @Id
    private String id;

    /**
     * 账号
     */
//    @Field(type = FieldType.Keyword)
    private String account;

    /**
     *  操作类型
     *  FieldType.Keyword   表示不分词
     */
    @Field(type = FieldType.Keyword)
    @FieldTag(enumType = OperateTypeEnum.class)
    private String operateType;

    /**
     *  访问路径
     */
    @Field(type = FieldType.Keyword)
    private String accessPath;

    /**
     *  ip
     */
    @Field(type = FieldType.Keyword)
    private String ip;

    /**
     *  日志内容
     */
    private String logContent;

    /**
     * 操作时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date operateDate;

}
